Option Strict Off
Option Explicit On

Imports System.Configuration

Public Class DiccionarioCodigo
    Private m_List As DataTable

    Public Sub Add(ByVal Codigo As String, ByVal Glosa As String)
        If m_List.Rows.Find(Codigo) Is Nothing Then
            Dim drNueva As DataRow = m_List.NewRow

            drNueva("ID") = Codigo
            drNueva("Glosa") = Glosa

            m_List.Rows.Add(drNueva)
        End If
    End Sub

    Public ReadOnly Property Lista() As DataTable
        Get
            Return m_List
        End Get
    End Property

    Public Sub Load(ByVal Diccionario As String)
        For Each Key As String In ConfigurationManager.AppSettings
            If Key.IndexOf(".", 0) >= 0 Then
                If Key.Split(".")(0).Equals(Diccionario) Then
                    Add(Key.Split(".")(1), ConfigurationManager.AppSettings(Key))
                End If
            End If
        Next
    End Sub

    Public Sub New()
        MyBase.New()

        m_List = New DataTable

        m_List.Columns.Add(New DataColumn("ID", System.Type.GetType("System.String")))
        m_List.Columns.Add(New DataColumn("Glosa", System.Type.GetType("System.String")))

        m_List.PrimaryKey = New DataColumn() {m_List.Columns(0)}
    End Sub

    Protected Overrides Sub Finalize()
        m_List = Nothing

        MyBase.Finalize()
    End Sub
End Class